package com.ujiuye.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbutils.QueryRunner;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MyUtils {

    public static final QueryRunner qr = new QueryRunner(new ComboPooledDataSource());
    /**
     * 字符串转日期
     *
     * @param str
     * @return
     */
    public static Date stringToDate(String str) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            return sdf.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return null;

    }

    /**
     * 字符串数组转字符串
     * @param arr
     * @return
     */
    public static String arrayToString(String[] arr) {
        StringBuilder sb = new StringBuilder();
        if (arr != null) {
            for (String s : arr) {
                sb.append(",").append(s);
            }
        }
        return sb.toString().substring(1);
    }
}
